home *** CD-ROM | disk | FTP | other *** search
/ Quick PC 61 / Quick PC 61.iso / I386 / INS.CAB / rcancel.vbs < prev    next >
Encoding:
Text File  |  2003-02-21  |  3.8 KB  |  181 lines

  1. REM
  2. REM LOCALIZATION
  3. REM
  4.  
  5. L_SWITCH_MESSAGEID    = "-m"
  6. L_SWITCH_SERVER        = "-s"
  7. L_SWITCH_INSTANCE_ID    = "-i"
  8.  
  9. L_DESC_PROGRAM    = "rcancel - Cancel message in NNTP virtual servers"
  10. L_DESC_MESSAGEID    = """<message-id>"" Specify message to cancel"
  11. L_DESC_SERVER        = "<server> Specify computer to configure"
  12. L_DESC_INSTANCE_ID    = "<virtual server id> Specufy virtual server id"
  13.  
  14. L_DESC_EXAMPLES         = "Examples:"
  15. L_DESC_EXAMPLE1         = "rcancel.vbs -m ""<uqjWStxCBHA.1240@nntpserver.microsoft.com>"""
  16.  
  17.  
  18. L_ERR_INVALID_INSTANCE_ID    = "Invalid instance identifier."
  19. L_ERR_INVALID_MESSAGEID        = "Invalid message identifier."    
  20. L_ERR_CANCEL_ERROR         = "Error canceling message: "
  21. L_ERR_CANCEL_SUCCESS        = "Message canceled."
  22.  
  23. REM
  24. REM END LOCALIZATION
  25. REM
  26.  
  27. REM
  28. REM --- Globals ---
  29. REM
  30.  
  31. dim g_dictParms
  32. dim g_admin
  33.  
  34. set g_dictParms = CreateObject ( "Scripting.Dictionary" )
  35.  
  36. REM
  37. REM --- Set argument defaults ---
  38. REM
  39.  
  40. g_dictParms(L_SWITCH_MESSAGEID)        = ""
  41. g_dictParms(L_SWITCH_SERVER)        = ""
  42. g_dictParms(L_SWITCH_INSTANCE_ID)    = "1"
  43.  
  44. REM
  45. REM --- Begin Main Program ---
  46. REM
  47.  
  48. if NOT ParseCommandLine ( g_dictParms, WScript.Arguments ) then
  49.     usage
  50.     WScript.Quit ( 0 )
  51. end if
  52.  
  53. set g_admin = CreateObject("NntpAdm.Groups")
  54.  
  55.  
  56. server = g_dictParms(L_SWITCH_SERVER)
  57. instance = g_dictParms(L_SWITCH_INSTANCE_ID)
  58. messageid = g_dictParms(L_SWITCH_MESSAGEID)
  59.  
  60. REM
  61. REM    Check arguments
  62. REM
  63. if ( messageid = "" ) then
  64.     usage
  65.     WScript.Quit 0
  66. end if
  67.     
  68. if NOT IsNumeric (instance) then
  69.     WScript.Echo L_ERR_INVALID_INSTANCE_ID
  70.     WScript.Quit 0
  71. end if
  72.  
  73. if ( Left(messageid,1) <> "<" OR Right(messageid,1) <> ">" ) then
  74.     WScript.echo L_ERR_INVALID_MESSAGEID
  75.     WScript.Quit 0
  76. end if
  77.  
  78. REM
  79. REM    Cancel message
  80. REM
  81. g_admin.Server        = server
  82. g_admin.ServiceInstance    = instance
  83. g_admin.CancelMessage( messageid )
  84.  
  85. REM
  86. REM    Show Result    
  87. REM
  88. if (err.number <> 0) then
  89.     WScript.echo L_ERR_CANCEL_ERROR
  90.     WScript.echo Err.Description & " (Error 0x" & Hex(Err.Number) & ")"
  91. else
  92.     WScript.echo L_ERR_CANCEL_SUCCESS
  93. end if
  94. WScript.Quit 0
  95.  
  96. REM
  97. REM
  98. REM --- End Main Program ---
  99. REM
  100. REM
  101.  
  102. REM
  103. REM ParseCommandLine ( dictParameters, cmdline )
  104. REM     Parses the command line parameters into the given dictionary
  105. REM
  106. REM Arguments:
  107. REM     dictParameters  - A dictionary containing the global parameters
  108. REM     cmdline - Collection of command line arguments
  109. REM
  110. REM Returns - Success code
  111. REM
  112.  
  113. Function ParseCommandLine ( dictParameters, cmdline )
  114.     dim     fRet
  115.     dim     cArgs
  116.     dim     i
  117.     dim     strSwitch
  118.     dim     strArgument
  119.  
  120.     fRet    = TRUE
  121.     cArgs   = cmdline.Count
  122.     i       = 0
  123.     
  124.     do while (i < cArgs)
  125.  
  126.         REM
  127.         REM Parse the switch and its argument
  128.         REM
  129.  
  130.         if i + 1 >= cArgs then
  131.             REM
  132.             REM Not enough command line arguments - Fail
  133.             REM
  134.  
  135.             fRet = FALSE
  136.             exit do
  137.         end if
  138.  
  139.         strSwitch = cmdline(i)
  140.         i = i + 1
  141.  
  142.         strArgument = cmdline(i)
  143.         i = i + 1
  144.  
  145.         REM
  146.         REM Add the switch,argument pair to the dictionary
  147.         REM
  148.  
  149.         if NOT dictParameters.Exists ( strSwitch ) then
  150.             REM
  151.             REM Bad switch - Fail
  152.             REM
  153.  
  154.             fRet = FALSE
  155.             exit do
  156.         end if 
  157.  
  158.         dictParameters(strSwitch) = strArgument
  159.  
  160.     loop
  161.  
  162.     ParseCommandLine = fRet
  163. end function
  164.  
  165. REM
  166. REM Usage ()
  167. REM     prints out the description of the command line arguments
  168. REM
  169.  
  170. Sub Usage
  171.     WScript.Echo L_DESC_PROGRAM
  172.     WScript.Echo vbTab & L_SWITCH_MESSAGEID & " " & L_DESC_MESSAGEID
  173.     WScript.Echo vbTab & L_SWITCH_SERVER & " " & L_DESC_SERVER
  174.     WScript.Echo vbTab & L_SWITCH_INSTANCE_ID & " " & L_DESC_INSTANCE_ID
  175.  
  176.     WScript.Echo
  177.     WScript.Echo L_DESC_EXAMPLES
  178.     WScript.Echo L_DESC_EXAMPLE1
  179.     WScript.Echo L_DESC_EXAMPLE2
  180. end sub
  181.